package com.easyCode.util;

import static java.lang.System.arraycopy;

/**
 * @author 大忽悠
 * @create 2022/12/3 16:27
 */
public class ModuleUtil {
    private static final String DELIMITER=".";

    public static String merge(String ... moduleNameArray){
        StringBuilder mergeModuleName=new StringBuilder();
        for (String moduleName : moduleNameArray) {
               if(StringUtil.isNullOrEmpty(moduleName)){
                   continue;
               }
               mergeModuleName.append(moduleName).append(DELIMITER);
        }
        return mergeModuleName.substring(0,mergeModuleName.length()-1);
    }


    public static String modifyModuleNameToActualPath(String basePath,String moduleName){
        String[] moduleNameList = moduleName.split("\\.");
        String[] res = new String[moduleNameList.length + 1];
        res[0]=basePath;
        arraycopy(moduleNameList,0,res,1,moduleNameList.length);
        return StringUtil.pathMerge(true,res);
    }
}
